<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../common/import.jsp" %>
<%@ taglib uri="/WEB-INF/privilege" prefix="p"%>
<html>
  <head>
     <style type="text/css">
     </style>
  </head>
  <body scroll="no">
  <script type="text/javascript">
       jQuery.ajaxSetup({cache: false});
       $(function(){
    	   $("#logTable").datagrid({
    		   //width: 600,
    		   nowrap: false,
    		   triped: false,
    		   fitColumns: true,
    		   url: '${ctx}/sys/log/list.do',
    		   columns: [[
    		             {field: 'ck', checkbox: true},
    		             //{field: 'title', title: '日志标题', width: 100, align: 'center'},
    		             {field: 'operateUser', title: '操作者', width: 100, align: 'center'},
    		             {field: 'operateType', title: '日志类型', width: 100, align: 'center'},
    		             {field: 'operateObj', title: '操作对象', width: 100, align: 'center'},
    		             {field: 'operateTime', title: '操作时间', width: 100, align: 'center'}
    		            ]],
    		   pagination: true,
    		   rownumbers: true,
    		   pageSize: 20,
    		   pageList: pageList
    	   });
       });
       
       function getSelectedRows(){
    	   var rows = $('#logTable').datagrid('getSelections');
    	   return rows;
       }
       function del(href){
    	   var rows = getSelectedRows();
    	   if (rows&&rows.length > 0){
    		   deleteConfirm(function(){
    			   var ps = "";
		           $.each(rows,function(i,n){
		        	   if(i==0) 
		        			ps += n.id;
		        		else
		        			ps += ","+n.id;
		        	});
		           $.blockUI();
    			   $.ajax({
		    			  url: href,   // 提交的页面
		    		      data: {ids: ps}, 
		    		      type: "POST",
		    		      success: function(data) {
		    		    	  $.unblockUI();
		    		        	if(data.success==true){
		    		        		showSuccessMsg();
		    		        		reloadGrid();
		    		        	}else{
		    		        		showFailAlert(data.msg);
		    		        	}
		    		      },
		    		      error: function(xhr) {
		    		    	  $.unblockUI();
		    		    	  showFailAlert2(xhr);
		    		      }
		    		  })
    		   });
    	   }else{
    		   showAlertMsg();
    	   }
    	   return false;
       }
       function view(href){
    	   var rows = getSelectedRows();
    	   if (rows&&rows.length==1){
    		   showWindow("查看操作日志", href+"?id="+rows[0].id);
    	   }else{
    		   showAlertMsg();
    	   }
    	   return false;
       }
       //刷新当前页
       function reloadGrid(){
    	   $("#logTable").datagrid("reload");
       }
       //重新刷新table
       function loadGrid(){
    	   $("#logTable").datagrid("load");
       }
       function queryForm(){
    	   var params = $('#logTable').datagrid('options').queryParams; //先取得 datagrid 的查询参数
    	   var fields =$('#queryForm').serializeArray(); //自动序列化表单元素为JSON对象
    	   $.each( fields, function(i, field){
    		   params[field.name] = field.value; //设置查询参数
           });   
    	   loadGrid();
       }
       function clearForm(){
    	   $('#queryForm').form('clear');
    	   queryForm();
       }
    </script>
    <div class="easyui-layout" data-options="fit:true">
    <div region="north" style=" overflow-y: hidden; overflow-x: hidden" border="false">
        <form id="queryForm" onSubmit="queryForm();return false;">
	        <table width="99.5%" style="text-align: right;padding-left: 5px;">
		        <td width="30px">日期:</td><td width="60px"><input id="startDate" name="startDate" type="text" class="easyui-datebox"></input></td>
		        <td width="10px">到</td><td width="60px"><input id="endDate" name="endDate" type="text" class="easyui-datebox"></input></td>
		        <td width="80px">操作者:</td><td width="60px"><input type="text" name="operateUser" value="" ></td>
			    <td width="85px"><a href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="queryForm();">查询</a></td>
			    <td width="85px"><a href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="clearForm();">重置</a></td>
			    <td></td>
			</table>
        </form>
		<div class="btabs">
		    <p:op code="sysOpeLogDel">
				<a class="easyui-linkbutton" data-options="plain:true" href="${ctx}/sys/log/delete.do" 
				onclick="return del(this.href);"><span class="icon icon-delete">&nbsp;</span>删除</a> 
			</p:op>
	    	<p:op code="sysOpeLogView">
				<a class="easyui-linkbutton" data-options="plain:true" href="${ctx}/sys/log/toView.do" 
				onclick="return view(this.href);"><span class="icon icon-view">&nbsp;</span>查看</a>
			</p:op> 
		</div>
    </div>
    <div region="center" style="padding: 1px;" border="false">
       <div id="logTable" fit="true" ></div>
    </div>
    </div>
  </body>
</html>
